package main

import "fmt"

func removeDuplicates(nums []int) int {
	k := len(nums)
	if k == 1 {
		return 1
	}

	tmp := nums[0]
	i, step := 1, 1
	for {
		if i == k {
			break
		}
		if nums[i] == tmp {
			if step == 2 {
				nums = append(nums[:i-1], nums[i:]...)
				k--
				continue
			}
			step = 2
			i++
			continue
		}
		tmp = nums[i]
		step = 1
		i++
		continue
	}
	return k
}

func main() {
	//s := []int{1, 1, 1, 2, 3, 4, 4, 4}
	s := []int{0, 0, 1, 1, 1, 2, 3, 3}
	fmt.Println(removeDuplicates(s))
}
